package com.huaxin.hxmoduleworkorder.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaxin.hxmoduleworkorder.dto.ResponseResult;
import com.huaxin.hxmoduleworkorder.dto.request.InspectionTemplateCreateReqDTO;
import com.huaxin.hxmoduleworkorder.dto.request.InspectionTemplatePageListReqDTO;
import com.huaxin.hxmoduleworkorder.dto.request.InspectionTemplateToggleStatusReqDTO;
import com.huaxin.hxmoduleworkorder.dto.request.InspectionTemplateUpdateReqDTO;
import com.huaxin.hxmoduleworkorder.models.InspectionTemplate;
import com.huaxin.hxmoduleworkorder.service.InspectionTemplateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Tag(name = "巡查模版")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/workorder/inspectionTemplate")
public class InspectionTemplateController {
    private final InspectionTemplateService inspectionTemplateService;

    @Operation(summary = "新增", description = "新增")
    @PostMapping("/create")
    public ResponseResult<InspectionTemplate> create(@RequestBody InspectionTemplateCreateReqDTO in) {
        return inspectionTemplateService.create(in);
    }

    @Operation(summary = "根据ID查询", description = "根据ID查询")
    @GetMapping("/get")
    public ResponseResult<InspectionTemplate> get(@Parameter(description = "ID", name = "id") @RequestParam(name = "id", required = true) String id) {
        return inspectionTemplateService.get(id);
    }

    @Operation(summary = "更新", description = "更新")
    @PostMapping("/update")
    public ResponseResult<String> update(@RequestBody InspectionTemplateUpdateReqDTO in) {
        return inspectionTemplateService.update(in);
    }

    @Operation(summary = "删除", description = "删除")
    @DeleteMapping("/{id}/delete")
    public ResponseResult<String> delete(@Parameter(description = "ID") @PathVariable String id) {
        return inspectionTemplateService.delete(id);
    }

    @Operation(summary = "获取分页列表", description = "获取分页列表")
    @PostMapping("/pageList")
    public ResponseResult<Page<InspectionTemplate>> pageList(@RequestBody InspectionTemplatePageListReqDTO in) {
        return inspectionTemplateService.pageList(in);
    }

    @Operation(summary = "启用/禁用")
    @PostMapping("/toggleStatus")
    public ResponseResult<String> toggleStatus(@RequestBody InspectionTemplateToggleStatusReqDTO in) {
        return inspectionTemplateService.toggleStatus(in);
    }
}
